<?php

function setSelectedCity(){
	echo $_SESSION['selectedCity'];
}	


function getTourList(){
	
	// Datenbankverbindung aufbauen
	$db = new mysqli('localhost', 'root', '', 'cityguide');
	$db->set_charset("utf8");
	if (mysqli_connect_errno()) {
    	printf("Connect failed: %s\n", mysqli_connect_error());
    	exit();
	}
	
	$query = "SELECT distinct TOUR.name FROM TOUR, CITY where CITY.name = ? and CITY.t_id = TOUR.t_id";

	if ($stmt = $db->prepare($query)) {
		$stmt->bind_param('s', $_SESSION['selectedCity']); # sind die Parameter die mit ? vordefiniert sind
		$stmt->execute();
    	$stmt->bind_result($tour);
    	
    	while ($row = $stmt->fetch()) {    		
    		echo "<li><a class='ui-link-inherit' href='detail_list.php?tour=" . $tour ."'>" . $tour . "</a></li>";
    		  		
    	}	
    	// Statement schliessen
		$stmt->close();
	}
	// Datenbankverbindung schliesssen
	$db->close();	
}
  
?>